package com.cryptooj.project.model.enums;

import org.apache.commons.lang3.ObjectUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public enum QuestionSubmitStatusEnum {
    WAITING("等待中",0),
    RUNNING("判题中",1),
    SUCCESS("成功",2),
    FAILED("失败",3);

    private String text;

    private Integer value;

    QuestionSubmitStatusEnum(String text,Integer value){
        this.text = text;
        this.value = value;
    }

    public static List<Integer> getValues(){
        return Arrays.stream(values())
                .map(item->item.value)
                .collect(Collectors.toList());
    }

    public static QuestionSubmitStatusEnum getEnumByValue(Integer value){
        if(ObjectUtils.isEmpty(value)){
            return null;
        }
        for (QuestionSubmitStatusEnum item : QuestionSubmitStatusEnum.values()){
            if(item.value.equals(value)){
                return item;
            }
        }
        return null;
    }

    public Integer getValue(){
        return value;
    }

    public String getText(){
        return text;
    }


}
